<template>
    <view class="pub_page pub_page_bg pub_chat_more pub_header_padding">
        <pub-head headerName="chat_more" :headerConfig="headerConfig"></pub-head>
        <pub-dialog v-show="dialogShow" dialogName="chat_more" :dialogConfig="dialogConfig"
            @dialogBack="dialogBack"></pub-dialog>
        <div class="pub_page_scroll page_box">
            <div v-if="chatType==1">
                <div class="group_info"
                    @click="$comFun.openWin('/pages/mine/friend_center',{userId:chatUserInfo.userId})">
                    <div class="chat_group_img chat_group_img_1">
                        <pub-image class="img" :src="chatUserInfo.userAvatar"></pub-image>
                    </div>
                    <div class="text">
                        <div class="p_3">{{ chatUserInfo.userName }}</div>
                    </div>
                </div>
                <div class="lis_div">
                    <div class="li" @click="chatDeal('to_clear_message')">
                        <div class="txt">清空聊天记录</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('message_remind')">
                        <div class="txt">消息免打扰</div>
                        <div class="right">
                            <text v-if="conversationInfo.messageRemindType!='AcceptAndNotify'"
                                class="icon-font-basic icon-b-switch-1"></text>
                            <text v-if="conversationInfo.messageRemindType=='AcceptAndNotify'"
                                class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('message_pinned')">
                        <div class="txt">置顶聊天</div>
                        <div class="right">
                            <text v-if="conversationInfo.isPinned" class="icon-font-basic icon-b-switch-1"></text>
                            <text v-if="!conversationInfo.isPinned" class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('open_set_friend_remark')">
                        <div class="txt">设置备注</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <!-- 
                    <div class="li">
                        <div class="txt">查看聊天内容</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li">
                        <div class="txt">文件记录</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div> -->
                </div>
                <div class="btn_div btn_div_1">
                    <div class="pub_btn" @click="chatDeal('to_delete_friend')">删除好友</div>
                </div>
            </div>
            <div v-if="chatType==2 && chatGroupInfo!=''">
                <div class="group_info" @click="chatDeal('open_group_info')">
                    <!-- :class="'chat_group_img_'+li" v-for="(li,key) in 9" -->
                    <div class="chat_group_img chat_group_img_1">
                        <pub-image class="img" :src="chatGroupInfo.groupAvatar"></pub-image>
                    </div>
                    <div class="text">
                        <div class="p_1">{{ chatGroupInfo.groupName }}</div>
                        <div class="p_2">群号：{{ chatGroupInfo.groupShowId }}</div>
                    </div>
                    <div class="more">
                        <!-- <pub-image class="icon" :src="'../../static/aimg/img_20.png'" :mode="'aspectFit'"></pub-image> -->
                        <text v-if="isGroupOwner" class="icon-font-basic icon-b-arrow-1-2"></text>
                    </div>
                </div>
                <div class="group_user_div">
                    <div class="title">群成员 {{ chatGroupInfo.memberCount }}/{{ chatGroupInfo.chatGroupMemberMax }}
                        <div class="more" @click="chatDeal('group_member_list')">更多 <text
                                class="icon-font-basic icon-b-arrow-1-2"></text></div>
                    </div>
                    <div class="lis">
                        <div class="li" v-for="(li,key) in chatGroupMemberList" :key="key"
                            @click="$comFun.openWin('/pages/mine/friend_center',{userId:li.userID})">
                            <pub-image class="img" :src="li.avatar"></pub-image>
                            <div class="name">{{ li.nick }}</div>
                        </div>
                        <div class="li" v-if="allowGroupAdd" @click="chatDeal('group_add')">
                            <pub-image class="img" :src="'../../static/aimg/img_19.png'"></pub-image>
                            <div class="name">添加好友</div>
                        </div>
                        <div class="li" v-if="isGroupOwner" @click="chatDeal('group_delete')">
                            <pub-image class="img" :src="'../../static/aimg/img_19.png'"></pub-image>
                            <div class="name">删除好友</div>
                        </div>
                    </div>
                </div>
                <div class="lis_div">
                    <div class="li" @click="chatDeal('to_clear_message')">
                        <div class="txt">清空聊天记录</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('open_group_notification')">
                        <div class="txt">群公告</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('open_group_introduce')">
                        <div class="txt">群介绍</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('message_remind')">
                        <div class="txt">消息免打扰</div>
                        <div class="right">
                            <text v-if="conversationInfo.messageRemindType=='AcceptNotNotify'"
                                class="icon-font-basic icon-b-switch-1"></text>
                            <text v-if="conversationInfo.messageRemindType=='AcceptAndNotify'"
                                class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <div class="li" @click="chatDeal('message_pinned')">
                        <div class="txt">置顶聊天</div>
                        <div class="right">
                            <text v-if="conversationInfo.isPinned" class="icon-font-basic icon-b-switch-1"></text>
                            <text v-if="!conversationInfo.isPinned" class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <!-- <div class="li" @click="chatDeal('group_member_mute')">
                        <div class="txt">群禁言管理</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div> -->
                    <div class="li" v-if="isGroupOwner" @click="chatDeal('to_group_member_all_mute')">
                        <div class="txt">全员禁言</div>
                        <div class="right">
                            <text v-if="chatGroupInfo.muteAllMembers" class="icon-font-basic icon-b-switch-1"></text>
                            <text v-else class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <div class="li" v-if="isGroupOwner" @click="chatDeal('to_group_is_open')">
                        <div class="txt">是否公开至社区</div>
                        <div class="right">
                            <text v-if="chatGroupInfo.isOpen" class="icon-font-basic icon-b-switch-1"></text>
                            <text v-else class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>
                    <div class="li" v-if="isGroupOwner" @click="chatDeal('to_group_join_type')">
                        <div class="txt">群成员邀请入群</div>
                        <div class="right">
                            <text v-if="chatGroupInfo.joinType==1" class="icon-font-basic icon-b-switch-1"></text>
                            <text v-else class="icon-font-basic icon-b-switch-2"></text>
                        </div>
                    </div>

                    <!-- 
                    
                    <div class="li">
                        <div class="txt">我在本群的昵称</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li">
                        <div class="txt">查找聊天记录</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li">
                        <div class="txt">消息免打扰</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li">
                        <div class="txt">置顶聊天</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div>
                    <div class="li">
                        <div class="txt">保存到通讯录</div>
                        <div class="right">
                            <text class="icon-font-basic icon-b-arrow-1-2"></text>
                        </div>
                    </div> -->
                </div>
                <div class="btn_div btn_div_2">
                    <div class="pub_btn" @click="chatDeal('to_dissolve_group')" v-if="isGroupOwner">
                        解散群聊</div>
                    <div class="pub_btn" @click="chatDeal('to_quit_group')" v-if="!isGroupOwner">
                        删除并退出</div>
                    <!-- <div class="pub_btn_normal">清空聊天记录</div> -->
                </div>
            </div>
        </div>


        <view class="pub_dialog dialog_friend_remark" v-if="friendRemarkAlert">
            <div class="d_box">
                <div class="d_title">设置备注</div>
                <div class="d_content">
                    <div class="input_div_new">
                        <div class="li">
                            <input class="input" v-model="friendRemark" type="text" placeholder="请输入" maxlength="10">
                        </div>
                    </div>
                </div>
                <div class="d_btns">
                    <div class="d_btn" @click="friendRemarkAlert = false">取消</div>
                    <div class="d_btn" @click="chatDeal('sure_set_friend_remark')">确定</div>
                </div>
            </div>
        </view>
        <view class="pub_dialog" v-if="openGroupAlertShow">
            <div class="d_box">
                <div class="d_title">公开至社区</div>
                <div class="d_content">
                    <div class="input_div_new">
                        <div class="li">
                            <picker class="picker" @change="chatCategoryListChange" :value="openGroupCategoryIndex"
                                :range="chatCategoryList" range-key="title">
                                <view class="picker_txt">所选分类：{{openGroupCategoryName||'请选择'}}</view>
                            </picker>
                        </div>
                    </div>
                    <div class="msg">公开至社区，将会扣除 {{ openGroup }} 金币</div>
                </div>
                <div class="d_btns">
                    <div class="d_btn" @click="openGroupAlertShow = false">取消</div>
                    <div class="d_btn" @click="chatDeal('sure_group_is_open')">确定</div>
                </div>
            </div>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            pagescrollTop: 0,
            headerConfig: {
                title: '聊天信息',//标题栏内容
                title_type: 2,
                left_type: 3,
            },
            dialogShow: false,
            dialogType: '',
            dialogConfig: {
                title: '提示',//标题栏内容
                content: ''
            },

            chatType: 1,//1单聊  2群聊
            chatUserInfo: '',//单聊时 用户信息
            chatGroupInfo: '',//群聊时 群聊信息
            chatGroupMemberList: [],

            userInfo: '',
            conversationID: '',
            conversationInfo: {
                messageRemindType: '',
                isPinned: false,
            },

            friendRemarkAlert: false,
            friendRemark: '',

            openGroup: 0,
            openGroupAlertShow: false,
            chatCategoryList: [],
            openGroupCategoryIndex: '',
            openGroupCategoryName: '',
            openGroupCategoryId: '',
        };
    },
    computed: {
        allowGroupAdd() {
            let bool = this.isGroupOwner || (!this.isGroupOwner && this.chatGroupInfo.joinType == 1)
            return this.chatGroupInfo.chatGroupMemberMax > this.chatGroupInfo.memberCount && bool
        },
        // 是否为群主
        isGroupOwner() {
            return this.chatGroupInfo.ownerID == this.userInfo.userId
        }
    },
    async onLoad(options) {
        console.log(111, options);
        this.userInfo = this.$comFun.getUserInfo();
        this.chatType = options.chatType || 1;
        const that = this;
        if (that.chatType == 1) {
            that.chatUserInfo = options.chatUserInfo ? JSON.parse(options.chatUserInfo) : '';
            if (that.chatUserInfo == '') return;
            that.conversationID = `C2C${that.chatUserInfo.userId}`;
        } else if (that.chatType == 2) {
            let chatGroupInfo = options.chatGroupInfo ? JSON.parse(options.chatGroupInfo) : '';
            if (chatGroupInfo == '') return;
            that.conversationID = `GROUP${chatGroupInfo.groupId}`;
            // console.log("chatGroupInfo", chatGroupInfo);

            let res = await this.$request.get('chat/getGroupInfo', {
                groupId: chatGroupInfo.groupId
            });
            if (res.code == 200) {
                chatGroupInfo.groupShowId = res.result?.id || '';
                chatGroupInfo.isOpen = res.result?.isOpen || false;
                chatGroupInfo.joinType = res.result?.joinType || 1;//1允许群成员邀请  2不允许群成员邀请（只能群主邀请）
            }

            that.$txChat.getGroupProfile({
                groupID: chatGroupInfo.groupId
            }).then(function (imResponse) {
                console.log("chat-getGroupProfile", imResponse.data.group);
                const info = imResponse.data.group;
                chatGroupInfo.chatGroupMemberMax = info.maxMemberCount;
                chatGroupInfo.memberCount = info.memberCount;
                chatGroupInfo.muteAllMembers = info.muteAllMembers;
                // chatGroupInfo.groupAddOpt = info.groupAddOpt;
                chatGroupInfo.ownerID = info.ownerID;
                chatGroupInfo.notification = info.notification;
                chatGroupInfo.introduction = info.introduction;
                that.chatGroupInfo = chatGroupInfo;

                that.getGroupMemberList();
                that.getConfig();
                that.getGroupCategory();

                uni.$on("dealGroupMember", (data) => {
                    if (data.type == 'delete') {
                        that.chatGroupInfo.memberCount = that.chatGroupInfo.memberCount - data.num;
                    } else if (data.type == 'add') {
                        that.chatGroupInfo.memberCount = that.chatGroupInfo.memberCount + data.num;
                    }
                    that.getGroupMemberList();
                })
                uni.$on("dealGroupInfo", (data) => {
                    if (data.dealType == 1) {
                        that.chatGroupInfo.groupName = data.data.groupName;
                        that.chatGroupInfo.groupAvatar = data.data.groupAvatar;
                    } else if (data.dealType == 2) {
                        that.chatGroupInfo.notification = data.data.notification;
                    } else if (data.dealType == 3) {
                        that.chatGroupInfo.introduction = data.data.introduction;
                    }
                })
            }).catch(function (imError) {
                console.warn('getGroupProfile error:', imError); // 获取群详细资料失败的相关信息
            });
        }
        that.getConversationInfo()
    },
    onPageScroll(res) {
        this.pagescrollTop = res.scrollTop;
    },
    methods: {
        dialogBack(data) {
            // console.log(data);
            this.dialogShow = false;
            if (data.name == 'chat_more' && data.key == 1) {
                this.chatDeal(this.dialogType)
            }
        },
        getConversationInfo() {
            const that = this;
            let promise = that.$txChat.getConversationProfile(that.conversationID);
            promise.then(function (imResponse) {
                let info = imResponse?.data?.conversation || '';
                if (info) {
                    that.conversationInfo = {
                        messageRemindType: info.messageRemindType || '',
                        isPinned: info.isPinned,
                    }
                }
                console.log("chat-getConversationProfile", info); // 会话资料
            }).catch(function (imError) {
                console.warn('getConversationProfile error:', imError); // 获取会话资料失败的相关信息
            });
        },
        async getConfig() {
            let configRes = await getApp().getConfigList();
            this.openGroup = configRes.openGroup;
        },
        async getGroupCategory() {
            const res = await this.$request.get('chat/getGroupCategory', {});
            if (res.code == 200 && res.result.length > 0) {
                this.chatCategoryList = res.result;
            }
        },
        chatCategoryListChange(e) {
            this.openGroupCategoryIndex = e.detail.value;
            this.openGroupCategoryName = this.chatCategoryList[e.detail.value].title;
            this.openGroupCategoryId = this.chatCategoryList[e.detail.value].id;
        },
        async chatDeal(type, data) {
            const that = this;
            switch (type) {
                case 'open_set_friend_remark':
                    this.friendRemarkAlert = true;
                    this.friendRemark = '';
                    break;
                case 'sure_set_friend_remark':
                    if (this.friendRemark.trim() == '') {
                        this.$comFun.toast('请填写备注信息');
                        return;
                    }
                    that.$comFun.openLoading();
                    const res_2 = await that.$request.get('chat/setFriendMark', {
                        userId: that.chatUserInfo.userId,
                        remark: that.friendRemark
                    });
                    // console.log(res_2);
                    that.$comFun.closeLoading();
                    if (res_2.code == 200) {
                        that.friendRemarkAlert = false;
                        that.chatUserInfo.userName = that.friendRemark;
                        that.$comFun.toast('设置成功');
                        uni.$emit("chatSetFriendRemark", {
                            remark: that.friendRemark
                        })
                    } else {
                        that.$comFun.toast(res_2.message);
                    }

                    break;
                case 'to_clear_message':
                    that.dialogShow = true;
                    that.dialogType = 'sure_clear_message',
                        that.dialogConfig = {
                            title: '提示',//标题栏内容
                            content: '是否确定清空聊天记录？'
                        }
                    break;
                case 'sure_clear_message':
                    that.dialogShow = false;
                    let conversationID = '';
                    if (this.chatType == 1) {
                        conversationID = `C2C${that.chatUserInfo.userId}`;
                    } else if (this.chatType == 2) {
                        conversationID = `GROUP${that.chatGroupInfo.groupId}`;
                    }
                    // 删除单一会话, 并清空会话历史消息
                    that.$txChat.deleteConversation(conversationID).then(function (imResponse) {
                        // 删除会话成功
                        that.$comFun.toast('清空成功');
                        uni.$emit('clear_message_back');
                        // uni.$emit("chatConversationListUpdate", {
                        //     chatType: that.chatType,
                        //     userId: that.chatUserInfo.userId
                        // })
                    }).catch(function (imError) {
                        console.warn('deleteConversation error:', imError); // 删除会话失败的相关信息
                        that.$comFun.toast('失败，请稍后再试');
                    });
                    break;
                case 'group_add':
                    that.$comFun.openWin('/pages/chat/group_member', {
                        openType: 1,
                        groupId: that.chatGroupInfo.groupId,
                        maxChoose: that.chatGroupInfo.chatGroupMemberMax - that.chatGroupInfo.memberCount
                    });
                    break;
                case 'group_delete':
                    that.$comFun.openWin('/pages/chat/group_member', {
                        openType: 2,
                        groupId: that.chatGroupInfo.groupId
                    });
                    break;
                case 'group_member_list':
                    that.$comFun.openWin('/pages/chat/group_member', {
                        openType: 3,
                        groupId: that.chatGroupInfo.groupId
                    });
                    break;
                case 'group_member_mute':
                    that.$comFun.openWin('/pages/chat/group_member', {
                        openType: 4,
                        groupId: that.chatGroupInfo.groupId
                    });
                    break;
                case 'to_group_member_all_mute':
                    that.dialogShow = true;
                    that.dialogType = 'sure_group_member_all_mute';
                    that.dialogConfig = {
                        title: '提示',//标题栏内容
                        content: `是否确定${that.chatGroupInfo.muteAllMembers ? '取消' : ''}全员禁言？`
                    }
                    break;
                case 'sure_group_member_all_mute':
                    that.$txChat.updateGroupProfile({
                        groupID: that.chatGroupInfo.groupId,
                        muteAllMembers: !that.chatGroupInfo.muteAllMembers,
                    }).then(function (imResponse) {
                        // 设置全体禁言成功
                        that.$comFun.toast('设置成功', imResponse);
                        that.chatGroupInfo.muteAllMembers = !that.chatGroupInfo.muteAllMembers;
                    }).catch(function (imError) {
                        // 设置全体禁言失败
                        console.warn('setMessageRemindType error:', imError);
                        that.$comFun.toast('失败，请稍后再试');
                    });
                    break;
                case 'to_group_join_type':
                    that.dialogShow = true;
                    that.dialogType = 'sure_group_join_type';
                    that.dialogConfig = {
                        title: '提示',//标题栏内容
                        content: `是否确定${that.chatGroupInfo.joinType == 1 ? '关闭' : '开启'}群成员邀请入群？`
                    }
                    break;
                case 'sure_group_join_type':
                    that.dialogShow = false;
                    that.$comFun.openLoading();
                    let joinType = that.chatGroupInfo.joinType == 1 ? 2 : 1;
                    const res_7 = await that.$request.post('chat/updateGroup', {
                        groupNumber: that.chatGroupInfo.groupId,
                        joinType: joinType
                    });
                    // console.log(res_7);
                    that.$comFun.closeLoading();
                    if (res_7.code == 200) {
                        that.chatGroupInfo.joinType = joinType
                        that.$comFun.toast('操作成功');
                    } else {
                        that.$comFun.toast(res_7.message);
                    }
                    break;
                case 'to_group_is_open':
                    if (that.chatGroupInfo.isOpen) {
                        that.dialogShow = true;
                        that.dialogType = 'sure_group_is_close';
                        that.dialogConfig = {
                            title: '提示',//标题栏内容
                            content: `是否确定关闭？关闭后将不会显示在社区`
                        }
                    } else {
                        this.openGroupCategoryIndex = '';
                        this.openGroupCategoryName = '';
                        this.openGroupCategoryId = '';
                        this.openGroupAlertShow = true;
                    }
                    break;
                case 'sure_group_is_close':
                    that.dialogShow = false;
                    that.$comFun.openLoading();
                    const res_4 = await that.$request.get('chat/closeToCommunity', {
                        groupNumber: that.chatGroupInfo.groupId,
                    });
                    // console.log(res_4);
                    that.$comFun.closeLoading();
                    if (res_4.code == 200) {
                        that.chatGroupInfo.isOpen = false;
                        that.$comFun.toast('关闭成功');
                    } else {
                        that.$comFun.toast(res_4.message);
                    }
                    break;
                case 'sure_group_is_open':
                    if (that.openGroupCategoryId == '') {
                        that.$comFun.toast('请选择分类');
                        return;
                    }
                    that.openGroupAlertShow = false;
                    that.$comFun.openLoading();
                    const res_5 = await that.$request.get('chat/openToCommunity', {
                        groupNumber: that.chatGroupInfo.groupId,
                        categoryId: that.openGroupCategoryId
                    });
                    // console.log(res_5);
                    that.$comFun.closeLoading();
                    if (res_5.code == 200) {
                        that.chatGroupInfo.isOpen = true;
                        that.$comFun.toast('操作成功');
                    } else {
                        that.$comFun.toast(res_5.message);
                    }
                    break;
                case 'to_dissolve_group':
                    that.dialogShow = true;
                    that.dialogType = 'sure_dissolve_group';
                    that.dialogConfig = {
                        title: '提示',//标题栏内容
                        content: '是否确定解散群聊？'
                    }
                    break;
                case 'sure_dissolve_group':
                    that.dialogShow = false;

                    that.$comFun.openLoading();
                    const res = await that.$request.get('chat/deleteGroup', {
                        groupNumber: that.chatGroupInfo.groupId
                    });
                    // console.log(res);
                    that.$comFun.closeLoading();
                    if (res.code == 200) {
                        that.$comFun.toast('解散成功');
                        uni.$emit("chatConversationListUpdate", {
                            chatType: that.chatType,
                            groupId: that.chatGroupInfo.groupId
                        })
                        setTimeout(() => {
                            that.$comFun.closeWin(2);
                        }, 1000)
                    } else {
                        that.$comFun.toast(res.message);
                    }
                    break;
                case 'to_quit_group':
                    that.dialogShow = true;
                    that.dialogType = 'sure_quit_group',
                        that.dialogConfig = {
                            title: '提示',//标题栏内容
                            content: '是否确定退出群聊？'
                        }
                    break;
                case 'sure_quit_group':
                    that.dialogShow = false;


                    that.$comFun.openLoading();
                    const res_3 = await that.$request.get('chat/exitGroup', {
                        groupNumber: that.chatGroupInfo.groupId
                    });
                    // console.log(res_3);
                    that.$comFun.closeLoading();
                    if (res_3.code == 200) {
                        that.$comFun.toast('退出成功');
                        uni.$emit("chatConversationListUpdate", {
                            chatType: that.chatType,
                            groupId: that.chatGroupInfo.groupId
                        })
                        setTimeout(() => {
                            that.$comFun.closeWin(2);
                        }, 1000)
                    } else {
                        that.$comFun.toast(res_3.message);
                    }
                    break;
                case 'to_delete_friend':
                    that.dialogShow = true;
                    that.dialogType = 'sure_delete_friend',
                        that.dialogConfig = {
                            title: '提示',//标题栏内容
                            content: '是否确定删除好友？'
                        }
                    break;
                case 'sure_delete_friend':
                    that.dialogShow = false;

                    that.$comFun.openLoading();
                    const res_1 = await that.$request.get('chat/deleteFriend', {
                        userId: that.chatUserInfo.userId
                    });
                    // console.log(res);
                    that.$comFun.closeLoading();
                    if (res_1.code == 200) {
                        that.$comFun.toast('删除成功');
                        uni.$emit("chatConversationListUpdate", {
                            chatType: that.chatType,
                            userId: that.chatUserInfo.userId
                        })
                        setTimeout(() => {
                            that.$comFun.closeWin(2);
                        }, 1000)
                    } else {
                        that.$comFun.toast(res_1.message);
                    }
                    break;
                case 'open_group_info':
                    if (this.isGroupOwner) {
                        this.$comFun.openWin('/pages/chat/group_info', {
                            groupInfo: JSON.stringify(this.chatGroupInfo),
                            openType: 1
                        })
                    }
                    break
                case 'open_group_notification':
                    this.$comFun.openWin('/pages/chat/group_info', {
                        groupInfo: JSON.stringify(this.chatGroupInfo),
                        openType: 2,
                    })
                    break
                case 'open_group_introduce':
                    this.$comFun.openWin('/pages/chat/group_info', {
                        groupInfo: JSON.stringify(this.chatGroupInfo),
                        openType: 3
                    })
                    break
                case 'message_remind':
                    let mParams = {};
                    if (that.chatType == 1) {
                        mParams = {
                            userIDList: [that.chatUserInfo.userId]
                        }
                    } else if (that.chatType == 2) {
                        mParams = {
                            groupID: that.chatGroupInfo.groupId,
                        }
                    }
                    // AcceptAndNotify接收
                    mParams.messageRemindType = that.conversationInfo.messageRemindType == 'AcceptAndNotify' ? that.$TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE : that.$TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE;
                    console.log(11, mParams);
                    that.$txChat.setMessageRemindType({
                        ...mParams,
                    }).then(function (imResponse) {
                        // 设置消息免打扰成功
                        that.$comFun.toast('设置成功');
                        that.conversationInfo.messageRemindType = mParams.messageRemindType;
                    }).catch(function (imError) {
                        // 设置消息免打扰失败
                        console.warn('setMessageRemindType error:', imError);
                        that.$comFun.toast('失败，请稍后再试');
                    });
                    break;
                case 'message_pinned':
                    that.$txChat.pinConversation({
                        conversationID: that.conversationID,
                        isPinned: !that.conversationInfo.isPinned
                    }).then(function (imResponse) {
                        // 置顶会话成功
                        that.$comFun.toast('设置成功');
                        that.conversationInfo.isPinned = !that.conversationInfo.isPinned;
                    }).catch(function (imError) {
                        const { code } = imError;
                        // code - 50002 会话 ID 无效
                        console.warn('pinConversation error:', imError); // 置顶会话失败的相关信息
                        that.$comFun.toast('失败，请稍后再试');
                    });
                    break;
                default:
                    break;
            }
        },
        getGroupMemberList() {
            const that = this;
            that.$txChat.getGroupMemberList({
                groupID: that.chatGroupInfo.groupId,
                count: 8,
                offset: 0,
            }).then(function (imResponse) {
                console.log("chat-getGroupMemberList", imResponse.data.memberList); // 群成员列表
                that.chatGroupMemberList = imResponse.data.memberList;
            }).catch(function (imError) {
                console.warn('getGroupMemberList error:', imError);
            });
        }
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/chat.scss";
</style>
